<?php
use yii\bootstrap\ActiveForm;
?>
<link rel="stylesheet" href="../static/dist/css/AdminLTE.min.css" type="text/css">
<link rel="stylesheet" href="../static/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/datatables/jquery.dataTables.css" type="text/css">
<link rel="stylesheet" href="../static/css/admin.css" type="text/css">
<link rel="stylesheet" href="../static/jBox/Skins/Metro/jbox.css" type="text/css">
<style>
    .dataTables_length{
        margin-top: 10px;
    }
    .dataTable>tbody>tr>td{
        vertical-align: middle;
        font-size: 0.8em;
        padding: 8px 18px;
    }
    .dataTable>thead>tr>th{
        vertical-align: middle;
        font-size: 0.8em;
    }
</style>
<div class="tabs-panel">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <!--<h3 class="box-title">Hover Data Table</h3>-->
                    规格组名称: <input class="depart-input" name="spec_group_name" id="spec_group_name" type="text" placeholder="">
                    <button type="button" class="btn btn-primary depart-modal" id="select_button" style="width: 100px;">查询</button> &nbsp;
                    <button type="button" class="btn btn-warning depart-modal" id="reset_button" style="width: 100px;">重置</button>
                    <!--部门:<select name="dept_id" id="dept_id"></select>-->
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <button type="button" class="btn btn-success depart-modal" id="add_button" style="width: 100px;">添加</button>
                    <table id="table_id_example" class="display">
                        <thead>
                        <tr>
                            <th>操作</th>
                            <th>规格ID</th>
                            <th>规格组名称</th>
                            <th>规格组类型</th>
                            <th>规格</th>
                            <th>排序</th>
                            <th><?=TITLE_STATUS?></th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="add-spec-group-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    添加规格组
                </h4>
            </div>
            <div class="modal-body">
                <form action="/goods-spec/add-spec-group" method="post" id="add_group_form">
                    <div class="box-body">

                        <div class="form-group">
                            <label for="mobile"><span class="text-danger">* </span>规格组名称</label>
                            <input type="text" style="width: 50%;" class="form-control" name="spec_group_name" id="spec_group_name_add" placeholder="规格组名称">
                        </div>

                        <div class="form-group">
                            <label for="mobile">排序</label>
                            <input type="text" style="width: 50%;" class="form-control" name="sort" placeholder="排序">
                        </div>

                        <div class="form-group">
                            <label for="exampleInputEmail1"><span class="text-danger">* </span>规格组类型</label>
                            <select name="spec_type" class="form-control" style="width: 50%;">
                                <option value="0">OTHER</option>
                                <option value="1">COLOR</option>
                                <option value="2">SIZE</option>
                            </select>
                        </div>

                        <div class="form-group">
                            <label for="exampleInputEmail1"><span class="text-danger">* </span>状态</label>
                            <select name="use_flg" class="form-control" style="width: 50%;">
                                <option value="1">启用</option>
                                <option value="0">禁用</option>
                            </select>
                        </div>
                    </div>

                    <!-- /.box-body -->
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <a type="button" class="btn btn-primary ajax_post_add_group">
                    提交
                </a>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<div class="modal fade" id="update-spec-group-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    编辑规格组
                </h4>
            </div>
            <div class="modal-body">
                <form action="/goods-spec/update-spec-group" method="post" id="update_group_form">
                    <div class="box-body">

                        <div class="form-group">
                            <label for="mobile"><span class="text-danger">* </span>规格组名称</label>
                            <input type="text" style="width: 50%;" class="form-control" name="spec_group_name" id="spec_group_name_update" placeholder="规格组名称">
                        </div>

                        <div class="form-group">
                            <label for="mobile">排序</label>
                            <input type="text" style="width: 50%;" id="spec_group_sort_update" class="form-control" name="sort" placeholder="排序">
                        </div>

                        <div class="form-group">
                            <label for="exampleInputEmail1"><span class="text-danger">* </span>规格组类型</label>
                            <select name="spec_type" id="spec_type_update" class="form-control" style="width: 50%;">
                                <option value="0">OTHER</option>
                                <option value="1">COLOR</option>
                                <option value="2">SIZE</option>
                            </select>
                        </div>

                        <div class="form-group">
                            <label for="exampleInputEmail1"><span class="text-danger">* </span>状态</label>
                            <select name="use_flg" id="spec_group_use_flg_update" class="form-control" style="width: 50%;">
                                <option value="1">启用</option>
                                <option value="0">禁用</option>
                            </select>
                        </div>
                    </div>
                    <input name="id" id="update_group_id" type="hidden">
                    <!-- /.box-body -->
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <a type="button" class="btn btn-primary ajax_post_update_group">
                    提交
                </a>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<div class="modal fade" id="spec-list-modal" style="background: rgba(236, 230, 230, 0.3);" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 50%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    规格列表
                </h4>
            </div>
            <div class="modal-body">
                <div class="box-header">
                    <!--<h3 class="box-title">Hover Data Table</h3>-->
                    规格名称: <input class="depart-input" name="spec_name" id="spec_name" type="text" placeholder="">
                    <input class="depart-input" name="spec_group_id" id="search_spec_group_id" type="hidden" value="0">
                    <input class="depart-input" name="check_spec_type" id="check_spec_type" type="hidden" value="0">
                    <button type="button" class="btn btn-primary depart-modal" id="select_spec_button" onclick="search_spec_list()" style="width: 100px;">查询</button> &nbsp;
                    <button type="button" class="btn btn-warning depart-modal" id="reset_spec_button" style="width: 100px;">重置</button>
                    <!--部门:<select name="dept_id" id="dept_id"></select>-->
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <button type="button" class="btn btn-success depart-modal" id="add_spec_button" style="width: 100px;">添加规格</button>
                    <table id="spec_id_example" class="display">
                        <thead>
                        <tr>
                            <th>操作</th>
                            <th>ID</th>
                            <th>规格名称</th>
                            <th>规格值</th>
                            <th>规格组</th>
                            <th>排序</th>
                            <th>状态</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<div class="modal fade" id="add-spec-modal" style="background: rgba(236, 230, 230, 0.3);" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 50%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    添加规格
                </h4>
            </div>
            <div class="modal-body">
                <form action="/goods-spec/add-spec" method="post" id="add_spec_form">
                    <div class="box-body">

                        <div class="form-group">
                            <label for="exampleInputEmail1">规格组</label>
                            <select id="find_spec_group" disabled class="form-control" style="width: 50%;">
                                <option value="0">请选择</option>
                                <?php foreach($list as $value){?>
                                    <option value="<?= $value['id']?>"><?= $value['spec_group_name']?></option>
                                <?php }?>
                            </select>
                        </div>
                        <input name="spec_group_id" type="hidden" id="add_spec_group_id">
                        <input name="check_img_val" type="hidden" id="check_img_val">
                        <div class="form-group">
                            <button type="button" class="btn btn-success depart-modal" id="add_input" style="width: 100px;">添加</button>
                            <table class="table table-hover" id="input_table">
                                <tr>
                                    <th>规格</th>
                                    <th>规格值</th>
                                    <th>操作</th>
                                </tr>
                            </table>
                        </div>
                    </div>
                </form>
                <div style="display: none">
                    <?php $form = ActiveForm::begin(['id'=>'upload_form_update','action'=>'/common/img-upload'],['options' => ['enctype' => 'multipart/form-data']]) ?>
                    <?= $form->field($model, 'img_url')->fileInput(['class' => 'upload_file_ot']) ?>
                    <?php ActiveForm::end() ?>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <a type="button" class="btn btn-primary ajax_post_add_spec">
                    提交
                </a>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<div class="modal fade" id="update-spec-modal" style="background: rgba(236, 230, 230, 0.3);" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 50%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    修改规格
                </h4>
            </div>
            <div class="modal-body">
                <form action="/goods-spec/update-spec" method="post" id="update_spec_form">
                    <div class="box-body">
                        <div class="form-group">
                            <label for="exampleInputEmail1">规格组</label>
                            <select id="select_spec_group_id" disabled class="form-control" style="width: 50%;">
                                <option value="0">请选择</option>
                                <?php foreach($list as $value){?>
                                    <option value="<?= $value['id']?>"><?= $value['spec_group_name']?></option>
                                <?php }?>
                            </select>
                        </div>

                        <div class="form-group">
                            <label for="exampleInputPassword1">规格名称</label>
                            <input type="text" name="spec_name" class="form-control" id="update_spec_name" placeholder="规格名称">
                        </div>

                        <div class="form-group">
                            <label for="exampleInputPassword1">规格值</label>
                            <input type="text" name="spec_val" class="form-control" id="update_spec_val" placeholder="规格值">
                        </div>

                        <div class="form-group">
                            <button type="button" class="btn btn-success depart-modal upload-img-btn-update" style="width: 100px;">上传图片</button>
                            <button style="display: none;" data-img="" type="button" class="btn btn-success depart-modal show-img-btn-update" style="width: 100px;">查看图片</button>
                        </div>
                        <input type="hidden" name="img_url" class="form-control" id="update_img_url">
                        <input type="hidden" name="id" class="form-control" id="update_spec_id">
                        <input type="hidden" name="spec_group_id" class="form-control" id="update_spec_group_id">

                        <div class="form-group">
                            <label for="exampleInputPassword1">排序</label>
                            <input type="text" style="width: 50%;" name="sort" class="form-control" id="update_spec_sort" placeholder="排序">
                        </div>

                        <div class="form-group">
                            <label for="exampleInputEmail1">状态</label>
                            <select id="update_spec_use_flg" name="use_flg" class="form-control" style="width: 50%;">
                                <option value="1">启用</option>
                                <option value="0">禁用</option>
                            </select>
                        </div>
                    </div>
                    <!-- /.box-body -->

                </form>
                <div style="display: none">
                    <?php $form = ActiveForm::begin(['id'=>'upload_form_update_update','action'=>'/common/img-upload'],['options' => ['enctype' => 'multipart/form-data']]) ?>
                    <?= $form->field($model, 'img_url')->fileInput(['class' => 'upload_file_update']) ?>
                    <?php ActiveForm::end() ?>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <a type="button" class="btn btn-primary ajax_post_spec_update">
                    提交
                </a>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<input type="hidden" name="imageBathUrl" id="imageBathUrl" value="<?php echo Yii::$app->params['imageBathUrl'] . '/' ?>">
<!-- 固定js -->
<script type="text/javascript" src="../static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="../static/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../static/plugins/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../static/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../static/jBox/jquery.jBox-2.3.min.js"></script>
<script type="text/javascript" src="../static/jBox/i18n/jquery.jBox-zh-CN.js"></script>
<!--图片上传插件用-->
<script type="text/javascript" src="../static/plugins/jquery.form.js"></script>
<!--图片显示用-->
<script type="text/javascript" src="../static/plugins/layer/layer.js"></script>
<!-- 自定义js -->
<script type="text/javascript" src="../static/app/global.js?version=<?=Yii::$app->params['version']?>"></script>
<script type="text/javascript" src="../static/app/goods-spec/index.js?version=<?=Yii::$app->params['version']?>"></script>